using System;
using System.Collections;
using System.ComponentModel;

namespace HtmlParser
{
	public class Tags
	{
		Hashtable _tags = new Hashtable();

		[FlagsAttribute]
		public enum TagType
		{
			UNKNOWN		= 1,
			INLINE		= 2,
			BLOCK		= 4,
			STANDALONE	= 8,
			HEAD		= 16,
			MIXED		= 32
		}

		[FlagsAttribute]
		public enum ParserAction
		{
			PARSE_HTML	= 1,
			DONTPARSE	= 2,
			PARSE_CSS	= 4,
		}

		public class TagInfo
		{
			TagType _type;
			ParserAction _action;
			string _name;

			public TagInfo(string name,ParserAction action,TagType type)
			{
				_name = name;
				_type = type;
				_action = action;
			}

			public string Name{get{return _name;}}
			public TagType Type{get{return _type;}}
			public ParserAction Action{get{return _action;}}
		}		

		public Tags()
		{
			_tags.Add("unknown!"	,new TagInfo("",			ParserAction.PARSE_HTML,	TagType.UNKNOWN));

			_tags.Add("script"		,new TagInfo("script",		ParserAction.DONTPARSE,		TagType.HEAD & TagType.MIXED));
			_tags.Add("style"		,new TagInfo("style",		ParserAction.DONTPARSE,		TagType.HEAD & TagType.MIXED));
			_tags.Add("textarea"	,new TagInfo("textarea",	ParserAction.DONTPARSE,		TagType.BLOCK));

			_tags.Add("br"			,new TagInfo("br",			ParserAction.PARSE_HTML,	TagType.STANDALONE));
			_tags.Add("img"			,new TagInfo("img",			ParserAction.PARSE_HTML,	TagType.STANDALONE));			
		}

		public TagInfo GetTagTypeInfo(string tagName)
		{
			if(_tags.ContainsKey(tagName.ToLower()))
			{
				return (TagInfo)_tags[tagName.ToLower()];
			}
			else
			{
				return (TagInfo)_tags["unknown!"];
			}
		}
	}
}
